<template>
    <!-- 物资管理-收料明细台账 -->
    <div class="main_content">
        <div class="scorll">
            <div class="content">
                <div class="search">
                    <div class="list">
                        <span>偏差结果:</span>
                        <CheckboxGroup v-model="social">
                            <Checkbox v-for="(val,index) in diffResultList" :key="index" :label="val.id">
                                <span>{{val.name}}</span>
                            </Checkbox>
                        </CheckboxGroup>
                    </div>
                    <div class="list">
                        <span>单据来源:</span>
                        <CheckboxGroup v-model="sourceType">
                            <Checkbox v-for="(val,index) in sourceList" :key="index" :label="val.id">
                                <span>{{val.name}}</span>
                            </Checkbox>
                        </CheckboxGroup>
                    </div>
                    <div class="list">
                        <span>收料类型:</span>
                        <CheckboxGroup v-model="recvSendList">
                            <Checkbox v-for="(val,index) in recvSendTypeList" :key="index" :label="val.id">
                                <span>{{val.name}}</span>
                            </Checkbox>
                        </CheckboxGroup>
                    </div>
                    <div class="list">
                        <span>选择日期:</span>
                        <DatePicker type="date" placeholder="请选择开始时间" style="width: 200px" v-model="startTime" :options="options" :clearable="false"></DatePicker>
                        <DatePicker type="date" placeholder="请选择结束时间" style="width: 200px;margin-left:20px;" v-model="endTime" :options="options" :clearable="false"></DatePicker>
                    </div>
                    <div class="list list1">
                        <div class="item1">
                            <span>材料类别:</span>
                            <Select v-model="matTypeName" clearable filterable style="width:200px" placeholder="请选择材料类别名称" @on-change="getmatList">
                                <Option v-for="item in matTypeList" :value="item.id" :key="item.id">{{item.name}}</Option>
                            </Select>
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <div class="item1">
                            <span>材料明细:</span>
                            <Select v-model="matName" clearable filterable style="width:200px" placeholder="请选择材料明细名称">
                                <Option v-for="item in matList" :value="item.id" :key="item.id" style="width:180px">{{item.name}}{{item.spec}}{{item.model}}</Option>
                            </Select>
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <div class="item1">
                            <span>发料单位:</span>
                            <Select v-model="receiveSupplierName" clearable filterable style="width:200px" placeholder="请选择发料单位名称">
                                <Option v-for="item in corpList" :value="item.id" :key="item.id">{{item.name}}</Option>
                            </Select>
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                    </div>
                    <div class="list list1">
                        <div class="item1">
                            <span>磅单编号:</span>
                            <Input v-model="code" placeholder="请输入磅单编号" style="width:200px" clearable />
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <div class="item1">
                            <span>仓库:</span>
                            <Select v-model="houseId" clearable filterable style="width:200px" placeholder="请选择仓库">
                                <Option v-for="item in houseList" :value="item.id" :key="item.id">{{item.name}}</Option>
                            </Select>
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <div class="item1">
                            <span>车牌号:</span>
                            <Input v-model="licensePlate" placeholder="请输入车牌号" style="width:200px" clearable />
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <input type="text" class="intBox" style="display:none" />
                        <div class="item1">
                            <el-button type="primary" @click="searchAll" size="small" plain>搜索</el-button>
                            <el-button type="info" @click="clear" style="margin-left:20px;" size="small" plain>重置</el-button>
                            <el-button type="primary" @click="exp" style="margin-left:20px;" size="small" plain :disabled="!btnList.includes('fmam/receiveNote/export')">导出</el-button>
                        </div>
                    </div>
                </div>
                <div class="table">
                    <el-table :data="list" style="width: 100%" v-show="list.length>0" :row-class-name="tableRowClassName">
                        <el-table-column type="expand">
                            <template slot-scope="props">
                                <ul class="materialList">
                                    <li v-for="(val,j) in props.row.noteMatList" :key="j" class="sub">
                                        <div style="width:21%">材料名称：{{val.matName}}</div>
                                        <div style="width:21%">规格型号：{{val.spec}}{{val.model}}</div>
                                        <div style="width:15%">实际数量：{{val.actualAmount}}{{val.deliveryUnitName}}</div>
                                        <div style="width:15%">运单数量：{{val.deliveryAmount}}{{val.deliveryUnitName}}</div>
                                        <div style="width:15%">实际重量：{{val.actualWeight || "-"}}吨</div>
                                        <div style="width:15%">运单重量：{{val.deliveryWeight || "-"}}吨</div>
                                        <img src="./../../assets/images/fmam/receive/diff1.png" v-if="val.diffResult ==-1" />
                                    </li>
                                </ul>
                            </template>
                        </el-table-column>
                        <el-table-column label="收料时间" prop="time"></el-table-column>
                        <el-table-column label="车牌号" prop="licensePlate" align="center"></el-table-column>
                        <el-table-column label="磅单编号" prop="code"></el-table-column>
                        <el-table-column label="收料类型" width="120" align="center">
                            <template slot-scope="scope">
                                <span v-if="scope.row.recvSendType == 101">采购</span>
                                <span v-if="scope.row.recvSendType == 102">调入</span>
                                <span v-if="scope.row.recvSendType == 103">甲供</span>
                                <span v-if="scope.row.recvSendType == 301">直入直出</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="发料单位名称" prop="sendSupplierName"></el-table-column>
                        <el-table-column label="毛重" width="100" align="center">
                            <template slot-scope="scope">
                                {{scope.row.grossWeight||'-'}}吨
                            </template>
                        </el-table-column>
                        <el-table-column label="皮重" width="100" align="center">
                            <template slot-scope="scope">
                                {{scope.row.tareWeight||'-'}}吨
                            </template>
                        </el-table-column>
                        <el-table-column label="净重"  width="100" align="center">
                            <template slot-scope="scope">
                                {{scope.row.netWeight||'-'}}吨
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" width="140" align="center" >
                            <template slot-scope="scope">
                                <el-button @click="getDtails(scope.row)" type="text" size="small">查看详情</el-button>
                                <el-button @click="getprint(scope.row)" type="text" size="small" :disabled="!btnList.includes('fmam/receiveNote/print')">打印</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div v-show="list.length == 0" class="no_data">
                        暂无数据
                    </div>
                </div>
                <div class="clearfix" v-show="list.length>0">
                    <div class="float-right">
                        <Page v-if="totalCount" style="margin: 20px 0;text-align: right;" :current.sync="current" :total="totalCount" :page-size="pageSize" show-elevator show-total @on-change="pageChange"></Page>
                    </div>
                </div>
            </div>
        </div>

        <Modal v-model="detailsModal" width="1200px;" :mask-closable="false" :footer-hide="true">
            <div id="pdfdownload" >
                <div class="title">
                    <div class="item" v-if="detailsObj.source != 2">
                        <span>偏差结果:</span>
                        <span v-if="detailsObj.diffResult ==0">正常</span>
                        <span v-if="detailsObj.diffResult ==1">超正差</span>
                        <span v-if="detailsObj.diffResult ==-1">超负差</span>
                    </div>
                    <div class="item">
                        <span v-if="detailsObj.source == 2">单据编号:</span>
                        <span v-else>磅单编号:</span>
                        <span>{{detailsObj.code}}</span>
                    </div>
                    <div class="item">
                        <span>组织机构:</span>
                        <span>{{detailsObj.deptName}}</span>
                    </div>
                </div>
                <hr />
                <div class="val">
                    <h2>
                        <span v-if="detailsObj.source == 2">基本信息</span>
                        <span v-else>过磅信息</span>
                    </h2>
                    <div class="tip">
                        <div class="item" v-if="detailsObj.source == 2">
                            <span>收料人:</span>
                            <span>{{detailsObj.checkUserName}}</span>
                        </div>
                        <div class="item" v-if="detailsObj.source == 2">
                            <span>收料时间:</span>
                            <span>{{detailsObj.checkTime}}</span>
                        </div>
                        <div class="item" v-if="detailsObj.source != 2">
                            <span>称毛时间:</span>
                            <span>{{detailsObj.grossWeightTime}}</span>
                        </div>
                        <div class="item" v-if="detailsObj.source != 2">
                            <span>称皮时间:</span>
                            <span>{{detailsObj.tareWeightTime}}</span>
                        </div>
                        <div class="item">
                            <span>单据来源:</span>
                            <span v-if="detailsObj.source == 0">称重</span>
                            <span v-if="detailsObj.source == 1">补录</span>
                            <span v-if="detailsObj.source == 2">移动验收</span>
                        </div>
                    </div>
                    <div class="tip" v-if="detailsObj.source != 2">
                        <div class="item" v-if="detailsObj.source != 2">
                            <span>进场称重人员:</span>
                            <span>{{detailsObj.grossUserName}}</span>
                        </div>
                        <div class="item" v-if="detailsObj.source != 2">
                            <span>出场称重人员:</span>
                            <span>{{detailsObj.tareUserName}}</span>
                        </div>
                        <div class="item" v-if="detailsObj.source != 2">
                            <span>打印次数:</span>
                            <span>{{detailsObj.printCnt}}</span>
                        </div>
                    </div>
                    <div class="tip">
                        <div class="item" >
                            <span>备注:</span>
                            <span>{{detailsObj.remark}}</span>
                        </div>
                    </div>
                </div>
                <hr />
                <div class="val1">
                    <h2>
                        <span v-if="detailsObj.source == 2">单据信息</span>
                        <span v-else>磅单信息</span>
                    </h2>
                    <div class="tip">
                        <p>磅单信息</p>
                        <div class="msg">
                            <div class="item">
                                <span>收料类型:</span>
                                <span v-if="detailsObj.recvSendType == 101">采购</span>
                                <span v-if="detailsObj.recvSendType == 102">调入</span>
                                <span v-if="detailsObj.recvSendType == 103">甲供</span>
                                <span v-if="detailsObj.recvSendType == 201">发料</span>
                                <span v-if="detailsObj.recvSendType == 202">废旧物资</span>
                                <span v-if="detailsObj.recvSendType == 203">调出</span>
                                <span v-if="detailsObj.recvSendType == 204">售出</span>
                                <span v-if="detailsObj.recvSendType == 301">直入直出</span>
                            </div>
                            <div class="item" v-if="detailsObj.recvSendType == 301">
                                <span>发料单位:</span>
                                <span>{{detailsObj.receiveSupplierName}}</span>
                            </div>
                            <div class="item">
                                <span>发料单位:</span>
                                <span>{{detailsObj.sendSupplierName}}</span>
                            </div>
                            <div class="item">
                                <span>车牌号:</span>
                                <span>{{detailsObj.licensePlate}}</span>
                            </div>
                            <div class="item">
                                <span>库房:</span>
                                <span>{{detailsObj.warehouseName}}</span>
                            </div>
                            <div class="item">
                                <span>使用部位:</span>
                                <span>{{detailsObj.partName}}</span>
                            </div>
                        </div>
                        <hr />
                        <p>运单图片</p>
                        <div class="msg">
                            <div class="item">
                                <span>原始单据编号:</span>
                                <span>{{detailsObj.deliveryCode}}</span>
                            </div>
                        </div>
                        <ul>
                            <li v-for="(val,i) in imgList" :key="i">
                                <div class="demo-image__preview">
                                    <el-image :src="val" :preview-src-list="[val]"></el-image>
                                </div>
                            </li>
                        </ul>
                        <hr />
                        <p>材料明细</p>
                        <div class="table" style="width:80%">
                            <table class="create-table" style="margin-top:20px;margin-bottom:20px;">
                                <thead>
                                    <tr>
                                        <th>材料</th>
                                        <th v-if="detailsObj.source == 2">批次编号</th>
                                        <th v-if="detailsObj.recvSendType == 301 && detailsObj.source == 2">运单数量</th>
                                        <th v-if="detailsObj.recvSendType == 301 && detailsObj.source == 2">实际数量</th>
                                        <th v-if="detailsObj.source == 2">确认数量</th>
                                        <th v-if="detailsObj.source != 2">数量</th>
                                        <th v-if="detailsObj.source != 2">重量（吨）</th>
                                        <th v-if="detailsObj.source != 2">扣量（吨）</th>
                                        <th v-if="detailsObj.source != 2">偏差</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr v-for="(item,index) in noteMatList" :key="index">
                                        <td>
                                            <div>{{item.matName}}</div>
                                            <div>
                                                <span>规格型号:</span>
                                                <span>{{item.spec}}{{item.model}}</span>
                                            </div>
                                            <div>
                                                <span>材料编码:</span>
                                                <span>{{item.matCode}}</span>
                                            </div>
                                        </td>
                                        <td v-if="detailsObj.source == 2">{{item.batchCode}}</td>
                                        <td v-if="detailsObj.recvSendType == 301 && detailsObj.source == 2">{{item.deliveryAmount}}{{item.deliveryUnitName}}</td>
                                        <td v-if="detailsObj.recvSendType == 301 && detailsObj.source == 2">{{item.actualAmount}}{{item.deliveryUnitName}}</td>
                                        <td v-if="detailsObj.source == 2">{{item.confirmAmount}}{{item.deliveryUnitName}}</td>
                                        <td v-if="detailsObj.source != 2">
                                            <div>{{item.actualAmount}}{{item.deliveryUnitName}}</div>
                                            <div>
                                                <span>运单:</span>
                                                <span>{{item.deliveryAmount}}{{item.deliveryUnitName}}</span>
                                            </div>
                                        </td>
                                        <td v-if="detailsObj.source != 2">
                                            <div>{{item.actualWeight}}吨</div>
                                            <div>
                                                <span>运单:</span>
                                                <span>{{item.deliveryWeight}}吨</span>
                                            </div>
                                        </td>
                                        <td v-if="detailsObj.source != 2">{{item.deductAmount}}</td>
                                        <td v-if="detailsObj.source != 2">
                                            <div>
                                                <span v-if="item.diffType == 1">{{item.actualDiff}}</span>
                                                <span v-if="item.diffType == 2">{{item.actualDiff}}%</span>
                                            </div>
                                            <div>
                                                <span v-if="item.diffType == 1">正负差标准:</span>
                                                <span v-if="item.diffType == 2">比例偏差:</span>
                                                <span v-if="item.diffType == 1">{{item.plusDiff}},</span>
                                                <span v-if="item.diffType == 1">{{item.minusDiff}}</span>
                                                <span v-if="item.diffType == 2">{{item.plusDiff}}%,</span>
                                                <span v-if="item.diffType == 2">{{item.minusDiff}}%</span>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="msg" v-if="detailsObj.source != 2">
                            <div class="item">
                                <span>毛重:</span>
                                <span>{{detailsObj.grossWeight}}吨</span>
                            </div>
                            <div class="item">
                                <span>皮重:</span>
                                <span>{{detailsObj.tareWeight}}吨</span>
                            </div>
                            <div class="item">
                                <span>净重:</span>
                                <span>{{detailsObj.netWeight}}吨</span>
                            </div>
                        </div>
                        <hr />
                        <div class="msg" v-if="detailsObj.source != 2">
                            <div class="item">
                                <span>实际总重量:</span>
                                <span>{{detailsObj.actualWeight}}吨</span>
                            </div>
                        </div>
                        <div class="msg" v-if="detailsObj.source != 2">
                            <div class="item">
                                <span>运单总重量:</span>
                                <span>{{detailsObj.deliveryWeight}}吨</span>
                            </div>
                        </div>
                        <div class="msg" v-if="detailsObj.source != 2">
                            <div class="item">
                                <span>确认重量:</span>
                                <span>{{confirmWeight}}吨</span>
                            </div>
                        </div>
                        <div class="msg" v-if="detailsObj.source != 2">
                            <div class="item">
                                <span>确认类型:</span>
                                <span v-if="detailsObj.confirmWeightType == 0">运单量</span>
                                <span v-if="detailsObj.confirmWeightType == 1">实际量</span>
                                <span v-if="detailsObj.confirmWeightType == 2">最小量</span>
                                <span v-if="detailsObj.confirmWeightType == 3">输入量</span>
                            </div>
                        </div>
                    </div>
                </div>
                <hr />
                <div class="val1">
                    <h2>
                        <span v-if="detailsObj.source == 2">图片信息</span>
                        <span v-else>进出场图片</span>
                    </h2>
                    <div class="tip" v-show="enterImgList.length>0">
                        <p>进场图片</p>
                        <ul>
                            <li v-for="(val,i) in enterImgList" :key="i">
                                <div class="demo-image__preview">
                                    <el-image :src="val" :preview-src-list="[val]"></el-image>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <hr v-show="enterImgList.length>0" />
                    <div class="tip" v-show="outImgList.length>0">
                        <p>出场图片</p>
                        <ul>
                            <li v-for="(val,i) in outImgList" :key="i">
                                <div class="demo-image__preview">
                                    <el-image :src="val" :preview-src-list="[val]"></el-image>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="tip" v-show="MImgList.length>0">
                        <p>收料图片</p>
                        <ul>
                            <li v-for="(val,i) in MImgList" :key="i">
                                <div class="demo-image__preview">
                                    <el-image :src="val" :preview-src-list="[val]"></el-image>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <hr v-show="MImgList.length>0" />
                    <div class="tip" v-show="DImgList.length>0">
                        <p>签名图片</p>
                        <ul>
                            <li v-for="(val,i) in DImgList" :key="i">
                                <div class="demo-image__preview">
                                    <el-image :src="val" :preview-src-list="[val]"></el-image>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="val1" v-show="detailsObj.source == 2">
                <h2>收料地点</h2>
                <div id="container55" class="container" style="height:500px;margin-top:10px"></div>
            </div>
            <div class="button"  style="margin-top:20px">
                <el-Button size="small" plain type="primary" v-print="'pdfdownload'">导出PDF</el-Button>
            </div>
        </Modal>
        
        <Modal v-model="printModal" width="1200px;" :mask-closable="false" :footer-hide="true">
            <div id="printDate" class="printDate">
                <div class="title">
                    <span style="margin-right:20px">{{printObj.deptName}}</span>
                    <span v-if="printObj.source == 2">移动收料单</span>
                    <span v-else>过磅收料单</span>
                </div>
                <div class="top">
                    <div class="left">
                        <div class="item">
                            <span>工程名称:</span>
                            <span>{{printObj.deptName}}</span>
                        </div>
                        <div class="item">
                            <span>单据编号:</span>
                            <span>{{printObj.code}}</span>
                        </div>
                        <div class="list">
                            <div class="print_l">
                                <ul>
                                    <li>
                                        <span>日期:</span>
                                        <span>{{printDate}}</span>
                                    </li>
                                    <li>
                                        <span>发料单位:</span>
                                        <span>{{printObj.sendSupplierName}}</span>
                                    </li>
                                </ul>
                            </div>
                            <div class="print_l">
                                <ul>
                                    <li>
                                        <span>收料类型:</span>
                                        <span v-if="printObj.recvSendType == 101">采购</span>
                                        <span v-if="printObj.recvSendType == 102">调入</span>
                                        <span v-if="printObj.recvSendType == 103">甲供</span>
                                        <span v-if="printObj.recvSendType == 201">发料</span>
                                        <span v-if="printObj.recvSendType == 202">废旧物资</span>
                                        <span v-if="printObj.recvSendType == 203">调出</span>
                                        <span v-if="printObj.recvSendType == 204">售出</span>
                                        <span v-if="printObj.recvSendType == 301">直入直出</span>
                                    </li>
                                    <li>
                                        <span>收料单位:</span>
                                        <span>{{printObj.receiveSupplierName}}</span>
                                    </li>
                                </ul>
                            </div>
                            <div class="print_r">
                                <ul>
                                    <li>
                                        <span>偏差结果:</span>
                                        <span v-if="printObj.diffResult ==0">正常</span>
                                        <span v-if="printObj.diffResult ==1">超正差</span>
                                        <span v-if="printObj.diffResult ==-1">超负差</span>
                                    </li>
                                    <li>
                                        <span>车牌号:</span>
                                        <span>{{printObj.licensePlate}}</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="right">
                        <vue-qr
                            id="qrcode"
                            :text="link"
                            :margin="10"
                            :size="500"
                            color-dark="#000"
                        />
                    </div>
                </div>
                <div class="center">
                    <p>材料信息</p>
                    <div class="table">
                        <table class="create-table" style="margin-top:20px;">
                            <thead>
                                <tr>
                                    <th>材料编码</th>
                                    <th>材料名称</th>
                                    <th>材料型号</th>
                                    <th v-if="printObj.source == 2">批次编号</th>
                                    <th>运单数量</th>
                                    <th v-if="printObj.source != 2">运单重量(吨)</th>
                                    <th>实际数量</th>
                                    <th v-if="printObj.source != 2">实际重量(吨)</th>
                                    <th v-if="printObj.source == 2">确认数量</th>
                                    <th v-if="printObj.source != 2">备注</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-for="(item,index) in printNoteMatList" :key="index">
                                    <td>
                                        <div>{{item.matCode}}</div>
                                    </td>
                                    <td>
                                        <div>{{item.matName}}</div>
                                    </td>
                                    <td>
                                        <div>{{item.spec}}</div>
                                    </td>
                                    <td v-if="printObj.source == 2">
                                        <div>{{item.batchCode}}</div>
                                    </td>
                                    <td>
                                        <div>{{item.deliveryAmount}}{{item.deliveryUnitName}}</div>
                                    </td>
                                    <td v-if="printObj.source != 2">
                                        <div>{{item.deliveryWeight}}{{item.deliveryUnitName}}</div>
                                    </td>
                                    <td>
                                        <div>{{item.actualAmount}}{{item.deliveryUnitName}}</div>
                                    </td>
                                    <td v-if="printObj.source != 2">
                                        <div>{{item.actualWeight}}{{item.deliveryUnitName}}</div>
                                    </td>
                                    <td v-if="printObj.source == 2">
                                        <div>{{item.confirmAmount}}{{item.deliveryUnitName}}</div>
                                    </td>
                                    <td v-if="printObj.source != 2">
                                        <span v-if="item.diffResult ==0">正常</span>
                                        <span v-if="item.diffResult ==1">超正差</span>
                                        <span v-if="item.diffResult ==-1">超负差</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td :colspan="printObj.source == 2?'4':'3'">合计</td>
                                    <td>{{printdeliveryAmount}}</td>
                                    <td v-if="printObj.source != 2">{{printdeliveryWeight}}</td>
                                    <td>{{printactualAmount}}</td>
                                    <td v-if="printObj.source != 2">{{printactualWeight}}</td>
                                    <td v-if="printObj.source == 2">{{printconfirmAmount}}</td>
                                    <td v-if="printObj.source != 2"></td>
                                </tr>
                                <tr >
                                   <td colspan='8'>备注:</td>
                                </tr>

                            </tbody>
                        </table>
                    </div>
                    <div class="weight" v-if="printObj.source != 2">
                        <div>
                            <span>毛重:</span>
                            <span>{{printObj.grossWeight}}吨</span>
                        </div>
                        <div>
                            <span>皮重:</span>
                            <span>{{printObj.tareWeight}}吨</span>
                        </div>
                        <div>
                            <span>净重:</span>
                            <span>{{printObj.netWeight}}吨</span>
                        </div>
                    </div>
                    <div class="weight" v-if="printObj.source != 2">
                        <div>
                            <span>确认重量:</span>
                            <span>{{printconfirmWeight}}吨</span>
                        </div>
                    </div>
                    <ul>
                        <li>
                            <div>现场材管:</div>

                        </li>
                        <li>
                            <div>材料主管:</div>
                        </li>
                        <li>
                            <div>收料员:</div>
                        </li>
                        <li>
                            <div>供货人:</div>
                        </li>
                    </ul>
                    <h5>共三联(现场材管,材料主管,供货人各执一联)</h5>
                </div>
            </div>
            <div class="button"  style="margin-top:20px">
                <el-Button size="small" plain type="primary" v-print="'printDate'">打印</el-Button>
            </div>
        </Modal>
    </div>
</template>

<script>
import { format ,initYMD} from "@/sever/utils.js";
import vueQr from 'vue-qr'
import {
    getWeighNoteList,
    getWeighNoteDetail,
    getAllSupplierList,
    getMatTypeOptionlist,
    getAllMatList,
    getFmamWeighNoteExport,
    getWarehouse,
} from "@/api/api.js";
export default {
    components: { vueQr },
    data() {
        return {
            link:"",
            options: {
                disabledDate(date) {
                    return date > Date.now();
                },
            },
            previewList: [],
            deptIdList: [],
            datalist: [],
            deptId: "",
            current: 1,
            pageSize: 10,
            pageNum: 1,
            totalCount: "",
            diffResultList: [
                {
                    id: 0,
                    name: "正常",
                },
                {
                    id: 1,
                    name: "超正差",
                },
                {
                    id: -1,
                    name: "超负差",
                },
            ],
            recvSendTypeList: [
                {
                    id: 101,
                    name: "采购",
                },
                {
                    id: 102,
                    name: "调入",
                },
                {
                    id: 103,
                    name: "甲供",
                },
                {
                    id: 301,
                    name: "直入直出",
                },
            ],
            recvSendList: [101, 102, 103, 301],
            social: [-1, 0, 1],
            endTime: new Date(),
            startTime: new Date(new Date().valueOf() - 604800000),
            matTypeName: "",
            matName: "",
            receiveSupplierName: "",
            code: "",
            list: [],
            detailsModal: false,
            detailsObj: {},
            enterImgList: [],
            outImgList: [],
            imgList: [],
            MImgList: [],
            DImgList: [],
            noteMatList: [],
            confirmWeight: "",
            flag: true,
            sourceList: [
                {
                    id: 0,
                    name: "称重",
                },
                {
                    id: 1,
                    name: "补录",
                },
                {
                    id: 2,
                    name: "移动收料",
                },
            ],
            sourceType: [0, 1, 2],
            corpList: [],
            matTypeList: [],
            matList: [],
            matId: "",
            printModal: false,
            printObj: {},
            printEnterImgList: [],
            printOutImgList: [],
            printMoadlImgList: [],
            printDate: "",
            printNoteMatList: [],
            printactualAmount: 0,
            printdeliveryAmount: 0,
            printactualWeight: 0,
            printdeliveryWeight: 0,
            printconfirmWeight: "",
            printconfirmAmount: 0,
            qrcodeId: "",
            btnList: [],
            licensePlate:"",
            houseList:[],
            houseId:"",
        };
    },
    computed: {
        porjectObject() {
            return this.$store.state.porjectObject;
        },
    },
    watch: {
        porjectObject(val, oldVal) {
            if (val.deptId != oldVal.deptId) {
                this.deptId = val.deptId;
                this.recvSendList = [101, 102, 103, 301];
                this.social = [-1, 0, 1];
                this.sourceType = [0, 1, 2];
                this.endTime = new Date();
                this.startTime = new Date(new Date().valueOf() - 604800000);
                this.matTypeName = "";
                this.matName = "";
                this.receiveSupplierName = "";
                this.code = "";
                this.licensePlate="";
                this.houseId ="";
                this.getAllList();
                this.getCorpList();
                this.getMatTypeList();
                this.getMatDetailsList();
            }
        },
    },
    methods: {
        setPreview(src) {
            this.previewList = [];
            this.previewList.push(src);
        },
        //获取磅房列表
        getHouseList(){
            let params = {
                deptId :this.deptId
            }
            getWarehouse(params).then(res=>{
                if(res.code == 200) {
                    this.houseList = res.data.list;
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        //获取供应商单位
        getCorpList() {
            let params = {
                deptId: this.deptId,
                category: 2,
            };
            getAllSupplierList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.corpList = res.data.list;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //查询材料类别列表
        getMatTypeList() {
            let params = {
                deptId: this.deptId,
            };
            getMatTypeOptionlist(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.matTypeList = res.data.list;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //查询材料明细
        getMatDetailsList() {
            let params = {
                deptId: this.deptId,
                matTypeId: this.matId,
            };
            getAllMatList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.matList = res.data.list;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        //获取材料类别
        getmatList(index) {
            this.matName = "";
            this.matId = index;
            this.getMatDetailsList();
        },
        exp(){
            let params = {
                weightNoteType: 1,
                deptId: this.deptId,
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                startTime: initYMD(this.startTime),
                endTime: initYMD(this.endTime),
                diffResultList: this.social,
                sourceList: this.sourceType,
                recvSendTypeList: this.recvSendList,
                matTypeId: this.matTypeName,
                matId: this.matName,
                sendSupplierId: this.receiveSupplierName,
                code: this.code,
                licensePlate:this.licensePlate,
                deptName:this.$store.state.porjectObject.name,
                warehouseId : this.houseId,
            };
            getFmamWeighNoteExport(params).then(res=>{
                if(res.code == 200) {
                   window.open(res.data.path)
                } else {
                   this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        getAllList() {
            let params = {
                weightNoteType: 1,
                deptId: this.deptId,
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                startTime: initYMD(this.startTime),
                endTime: initYMD(this.endTime),
                diffResultList: this.social,
                sourceList: this.sourceType,
                recvSendTypeList: this.recvSendList,
                matTypeId: this.matTypeName,
                matId: this.matName,
                sendSupplierId: this.receiveSupplierName,
                code: this.code,
                licensePlate:this.licensePlate,
                warehouseId : this.houseId
            };
            getWeighNoteList(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.list = res.data.list;
                        this.totalCount = res.data.total;
                        for (let i in this.list) {
                            let arr = [];
                            for (let j in this.list[i].noteMatList) {
                                arr.push(
                                    this.list[i].noteMatList[j].diffResult
                                );
                            }
                            this.list[i]["diffResultList"] = arr;
                        }
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        pageChange(index) {
            this.pageNum = index;
            this.getAllList();
        },
        searchAll() {
            if (
                new Date(this.startTime).getTime() >
                new Date(this.endTime).getTime()
            ) {
                this.$Modal.warning({
                    title: "错误",
                    content: "结束日期不能小于开始日期",
                });
                return;
            }
            this.getAllList();
        },
        getDtails(item) {
            this.confirmWeight = item.confirmWeight;
            this.detailsModal = true;
            this.enterImgList = [];
            this.imgList = [];
            this.outImgList = [];
            this.MImgList = [];
            this.DImgList = [];
            let params = {
                id: item.id,
            };
            getWeighNoteDetail(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.detailsObj = res.data;
                        this.noteMatList = res.data.noteMatList;
                        if (this.detailsObj.noteImgList.length > 0) {
                            this.detailsObj.noteImgList.forEach((i) => {
                                if (i.type == 1) {
                                    //进场图片
                                    this.enterImgList.push(i.imgUrl);
                                } else if (i.type == 2) {
                                    //出场图片
                                    this.outImgList.push(i.imgUrl);
                                } else if (i.type == 3) {
                                    //运单图片
                                    this.imgList.push(i.imgUrl);
                                } else if (i.type == 4) {
                                    //移动验收
                                    this.MImgList.push(i.imgUrl);
                                } else if (i.type == 5) {
                                    //电子签名
                                    this.DImgList.push(i.imgUrl);
                                }
                            });
                        }
                        if (this.detailsObj.source == 2) {
                            var map = new AMap.Map("container55", {
                                zoom: 14,
                                center: [res.data.lng, res.data.lat],
                            });
                            var marker;
                            marker = new AMap.Marker({
                                map: map,
                                icon:
                                    "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
                                position: [res.data.lng, res.data.lat],
                                offset: new AMap.Pixel(-20, -40),
                            });
                        }
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        getprint(item) {
            this.qrcodeId = item.guid;
            let url = ''
            if(process.env.NODE_ENV === "development" || process.env.NODE_ENV === "testing") {
                //开发环境 / 测试环境
                url = 'http://mtest.anculsai.com';
            }else if (process.env.NODE_ENV === "production") {
                //正式环境
                url = 'https://m.anculsai.com';
            }
            this.link = url + "/ms/pages/weightNote.html?guid=" + this.qrcodeId;
            this.printOutImgList = [];
            this.printEnterImgList = [];
            this.printMoadlImgList = [];
            this.printconfirmWeight = item.confirmWeight;
            this.printDate = item.time.substring(0, 10);
            this.printModal = true;
            this.printactualAmount = 0;
            this.printdeliveryAmount = 0;
            this.printactualWeight = 0;
            this.printdeliveryWeight = 0;
            this.printconfirmAmount = 0;
            let params = {
                id: item.id,
            };
            getWeighNoteDetail(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.printObj = res.data;
                        this.printNoteMatList = res.data.noteMatList;
                        for (let i = 0; i < this.printNoteMatList.length; i++) {
                            this.printactualAmount += this.printNoteMatList[i].actualAmount || 0;
                            this.printdeliveryAmount += this.printNoteMatList[i].deliveryAmount || 0;
                            this.printactualWeight += this.printNoteMatList[i].actualWeight;
                            this.printdeliveryWeight += this.printNoteMatList[i].deliveryWeight || 0;
                            this.printconfirmAmount += this.printNoteMatList[i].confirmAmount || 0;
                        }
                        if(String(this.printactualAmount).indexOf('.')!=-1){
                            if(String(this.printactualAmount).length>6){
                                this.printactualAmount = this.printactualAmount.toFixed(3)
                            }
                        }

                        if(String(this.printdeliveryAmount).indexOf('.')!=-1){
                            if(String(this.printdeliveryAmount).length>6){
                                this.printdeliveryAmount = this.printdeliveryAmount.toFixed(3)
                            }
                        }

                        if(String(this.printactualWeight).indexOf('.')!=-1){
                            if(String(this.printactualWeight).length>6){
                                this.printactualWeight = this.printactualWeight.toFixed(3)
                            }
                        }

                        if(String(this.printdeliveryWeight).indexOf('.')!=-1){
                            if(String(this.printdeliveryWeight).length>6){
                                this.printdeliveryWeight = this.printdeliveryWeight.toFixed(3)
                            }
                        }

                        if(String(this.printconfirmAmount).indexOf('.')!=-1){
                            if(String(this.printconfirmAmount).length>6){
                                this.printconfirmAmount = this.printconfirmAmount.toFixed(3)
                            }
                        }

                        if (this.printObj.noteImgList.length > 0) {
                            this.printObj.noteImgList.forEach((i) => {
                                if (i.type == 1) {
                                    //进场图片
                                    this.printEnterImgList.push(i.imgUrl);
                                } else if (i.type == 2) {
                                    //出场图片
                                    this.printOutImgList.push(i.imgUrl);
                                } else if (i.type == 4) {
                                    //移动收料
                                    this.printMoadlImgList.push(i.imgUrl);
                                }
                            });
                        }
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        clear() {
            this.recvSendList = [101, 102, 103, 301];
            this.social = [-1, 0, 1];
            this.sourceType = [0, 1, 2];
            this.endTime = new Date();
            this.startTime = new Date(new Date().valueOf() - 604800000);
            this.matTypeName = "";
            this.matName = "";
            this.receiveSupplierName = "";
            this.code = "";
            this.licensePlate = "";
            this.houseId = "";
            this.getAllList();
        },
        // 表格样式
        tableRowClassName({row}) {
            if (row.diffResultList.includes(-1)) {
                return 'redLable';
            }
        }
    },
    beforeDestroy() {
        if(localStorage.getItem('logTime')){
            localStorage.removeItem('logTime')
        }
    },
    mounted() {
        this.deptId = this.$store.state.porjectObject.deptId;
        this.btnList = JSON.parse(localStorage.getItem("arr"));
        if(localStorage.getItem('logTime')){
            this.endTime = initYMD(JSON.parse(localStorage.getItem('logTime')));
            this.startTime = initYMD(new Date(new Date(JSON.parse(localStorage.getItem('logTime'))).valueOf() - 604800000))
        }
        this.getAllList();
        this.getCorpList();
        this.getMatTypeList();
        this.getMatDetailsList();
        this.getHouseList();
    },
};
</script>


<style scoped lang="less">
@import "./../../assets/style/themeBase.less";
@import "./../../assets/style/base.less";
@import "./../../assets/style/pdf.less";
.el-table__row {
    background: #666 !important;
}
@import "./../../assets/style/print.less";
//  @import url("./../../assets/style/print.css") print;
/deep/.el-image-viewer__wrapper {
    top: 0;
    left: 200px;
    .el-icon-circle-close {
        color: #fff;
    }
    .el-image-viewer__prev,
    .el-image-viewer__next {
        display: none;
    }
}
// .main_content{
//     background-color: #F5F5F5;
// }
</style>
<style>
@media print {
    #printDate {
        margin-left: 5mm;
        margin-right: 5mm;
        width: 275mm;
        font-size: 16px;
    }
}
</style>

